import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;

public class StereoSwing extends JFrame
{
    private JTabbedPane tabbedPane; //Not assigned yet.

    private static final long serialVersionUID = 999;
    
    public StereoSwing()
    {
      
        // Create a frame object to add the 
        // application GUI components to.
      
        super("A Java(TM) Technology Dive Log");
        
        // Closes from title bar
        // and from menu
        addWindowListener(new WindowAdapter() 
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });
         
        // Tabbed pane with panels for Jcomponents
        // Instantiate JTabbedPane with keyword new        
        tabbedPane = 
             new JTabbedPane(SwingConstants.LEFT);
        // Calls method to set color
        tabbedPane.setBackground(Color.blue);
        tabbedPane.setForeground(Color.white);
        
        populateTabbedPane();
        buildMenu();
        getContentPane().add(tabbedPane);
        pack();       

    }// Ends constructor

    private void populateTabbedPane()
    {
        tabbedPane.addTab(
            "Welcome",
            null,
            new JPanel(),
            "Welcome to the Dive Log");

        tabbedPane.addTab(
	    "Diver Data",
            null,
            new JPanel(),
           "Click here to enter diver data");
                               
        tabbedPane.addTab(
	   "Log Dives",
           null,
           new JPanel(),
           "Click here to enter dives");
                               
        tabbedPane.addTab(
	  "Statistics",
           null,
           new JPanel(),
           "Click here to calculate dive statistics");
                               
        tabbedPane.addTab(
	   "Favorite Web Site",
           null,
           new JPanel(),
           "Click here to see a web site");                
        tabbedPane.addTab(
	   "Resources",
           null,
           new JPanel(),
           "Click here to see a list of resources");         
    } //Ends populateTabbedPane method

    // Method header
    private void buildMenu()
    {
        // Instantiates JMenuBar, JMenu,
        // and JMenuItem.
        JMenuBar mb = new JMenuBar();
        JMenu filemnu = new JMenu("File");
        JMenuItem openitm = new JMenu("Open");
        JMenuItem exititm = new JMenuItem("Exit");
        //Closes the application from the Exit 
        //menu item.
        exititm.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                System.exit(0);
            }
             
        });// Ends method

        //Adds the item to the menu object
        filemnu.add(openitm);
        filemnu.add(exititm);
        //Adds the menu object with item
        //onto the menu bar
        mb.add(filemnu); 
        //Sets the menu bar in the frame
        setJMenuBar(mb);
    }
    public static void main(String[] args)
    { 
        StereoSwing dl = new StereoSwing();
        dl.setSize(765, 690);
        dl.setBackground(Color.white);
        dl.setVisible(true);
    }
    
}